#include "StdAfx.h"
#include "CdrModel.h"
#include "UserInfo.h"


CdrModel::CdrModel(void)
{
	m_id = -1;
	m_userID = 0;
	m_callee = _T("");
	m_holdTm = 0;
	m_callTime = 0;
}

CdrModel::~CdrModel(void)
{
}

void CdrModel::parseFromJson(Json::Value& jsonData)
{
	if (!jsonData["id"].isNull()) 
	{
		this->m_id = jsonData["id"].asInt64();
	}
	if (!jsonData["userID"].isNull()) 
	{
		this->m_userID = jsonData["userID"].asInt();
	}
	if (!jsonData["callee"].isNull()) 
	{
		this->m_callee = jsonData["callee"].asCString();
	}
	if (!jsonData["holdTm"].isNull()) 
	{
		this->m_holdTm = jsonData["holdTm"].asInt();
	}
	if (!jsonData["callTime"].isNull()) 
	{
		this->m_callTime = jsonData["callTime"].asInt();
	}
	if (!jsonData["recordName"].isNull()) 
	{
		this->m_recordName = jsonData["recordName"].asCString();
	}

	UserInfo* pMyself = UserInfo::getInstance();
	if (pMyself->m_position < Branch_Mgr && pMyself->m_id != m_userID)
	{
		CString strShowText;
		strShowText.Format(_T("%s****%s"), m_callee.Mid(0, 3), m_callee.Mid(7));
		m_callee = strShowText;
	}
}
